<template>
  <div class='meetings-add'>
    <div class="meetings-nt">
      <div v-for="(item,index) in meetingsData">
        <span class="meetings-label">{{item.label}}：</span>
        <el-input v-if="item.type=='input'" v-model="$store.state.add.info[item.key]" clearable placeholder="请输入内容"></el-input>
        <el-date-picker v-else-if="item.type=='date'" value-format='yyyy-MM-dd HH:mm:ss' clearable  v-model="$store.state.add.info[item.key]" @change="changeTime" type="datetime" placeholder="选择日期时间">
        </el-date-picker>
      </div>
      <div>
        <el-button v-for="(item,index) in btnsData" :disabled="settime.isRest" v-if="item.show" :title="item.label" :key="index" :type="item.type" class="btn-add fr" @click="item.click">{{item.label}}</el-button>
      </div>
    </div>
    <div class="meetings-tab">
      <Tabs></Tabs>
    </div>
  </div>
</template>
<script>
import Tabs from './tabs/tabs'
export default {
  components: {Tabs},
  name: "",
  data() {
    return {
      input3:'',
      meetingsData: [
        { key: "meetName", label: "会议名称", type: "input" },
        { key: "meetDate", label: "会议时间", type: "date" }
      ],
      btnsData:[
        { label: "保存会议", type: "primary", click: this.save, show:true},
        // { label: "返回", type: "primary", click: this.doback, show:!this.showSearc}
      ],
      meetingInfo: {},
      showSearch:true,

      settime:{
        rest:null,
        isRest:false,
      }
    };
  },
  methods: {
    changeTime(val){
      // this.$store.state.add.info.meetDate
    },
    save(){
      var params=JSON.parse(JSON.stringify(this.$store.state.add.info))
      if(!params.meetName){
        _g.toMessage({status:1,msg:'会议名称不能为空'})
        return
      }else if(!params.meetDate){
        _g.toMessage({status:1,msg:'会议时间不能为空'})
        return
      }else if(!params.userData||params.userData.length==0){
        _g.toMessage({status:1,msg:'参会人员不能为空'})
        return
      }else if(!params.topicIds||params.topicIds.length==0){
        _g.toMessage({status:1,msg:'议题不能为空'})
        return
      }
      params.userData=params.userData.join(',')
      params.topicIds=params.topicIds.join(',')
      params.depIds=params.depIds.join(',')

      if(_g.getRouterParams(this).id)params.id=_g.getRouterParams(this).id

      var url=_g.getRouterPath(this)=='/manageMeetings/add'?'meeting/save.do':'meeting/updata.do'
      
      _g.apiPost(url,params).then(res=>{
        _g.toMessage(res)
        if(!res.error){
          this.settime.isRest=true
          this.settime.apiPost=setTimeout(()=>{
            this.settime.isRest=false
          },6000)
          this.$router.push('/manageMeetings/records')
        }
      })
    },
    doback(){
      this.$router.go(-1)
    }
  },
  beforeDestroy(){
    clearTimeout(this.settime.rest)
  }
};
</script>
<style lang="scss" scoped>
.meetings-add {
  padding: 0 20px;
  box-sizing: border-box;
  flex-grow: 1;
  display: flex;
  flex-direction: column;

  .meetings-nt {
    margin: 15px 0;
    display: flex;
    min-height: 40px;

    > div {
      display: flex;
      margin-right: 20px;
    }
  }
  .meetings-label {
    display: inline-block;
    width: 80px;
    font-size: 14px;
    line-height: 40px;
    text-align: center;
  }
  .meetings-tab{
    flex-grow: 1;
    display: flex;
    flex-direction: column;
  }
  
  .btn-add{
    margin-right: 20px;
    padding: 0 25px;
  }
}
</style>